package com.sds.shop.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import com.sds.fw.dao.AbDao;
import com.sds.shop.vo.CategoryVO;
import com.sds.shop.vo.CodeVO;

public class CodeDAO extends AbDao{
	private static CodeDAO cDao = new CodeDAO();
	public static CodeDAO getInstance(){
		return cDao;
	}
	

	public ArrayList<CodeVO> getCList(){
		ArrayList<CodeVO> cList = new ArrayList<CodeVO>();
		Connection conn = null;
		PreparedStatement ps = null;
		ResultSet rs = null;
		try{
			conn = connect();
			
			
			
			StringBuffer query = new StringBuffer();
			query.append("SELECT cd_No, cd_Nm, cd_Desc, cd_Group_No FROM tb_code where cd_NO like 'C%'");
			
			ps = conn.prepareStatement( query.toString() );

			rs = ps.executeQuery();
			while(rs.next()){
				CodeVO cvo = new CodeVO();
			    cvo.setCdNo(rs.getString(1));
			    cvo.setCdNm(rs.getString(2));
			    cvo.setCdDesc(rs.getString(3));
			    cvo.setCdGroupNo(rs.getString(4));
				cList.add(cvo);
			}
			close(conn, ps, rs);
		}catch(Exception ex){
			System.out.println("getCategoryList exception : " + ex);
			close(conn, ps, rs);
		}
		
		return cList;

	}
}
